package {
	import org.flixel.*;
	
	public class Utility {
		
		public static function getLength(v:FlxPoint):Number {
			return Math.sqrt((v.x * v.x) + (v.y * v.y));
		}
		
		public static function normalize(v:FlxPoint):Number {
			var length:Number = Math.sqrt((v.x * v.x) + (v.y * v.y));
			if (length <= 0) {
				v.x = 0;
				v.y = 0;
			}
			else {
				v.x /= length;
				v.y /= length;
			}
			return length;
		}
	
		public static function scale(v:FlxPoint, scale:Number):FlxPoint {
			v.x *= scale;
			v.y *= scale;
			return v;
		}
		
		public static function add(v:FlxPoint, w:FlxPoint):FlxPoint {
			return new FlxPoint(v.x + w.x, v.y + w.y);
		}
	}
}